/*
 * Copyright (C) 2004, Velocityme Partnership
 * ReassignResponsibilityActionForm.java
 *
 * Created on 23 May 2005, 09:39
 */

package com.velocityme.www.actionforms;

import java.util.ArrayList;
import java.util.Collection;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.upload.FormFile;
import org.apache.struts.upload.MultipartRequestHandler;

/**
 *
 * @author  Robert
 */
public class ReassignResponsibilityActionForm extends ActionForm {
    
    private String m_message;
    
    private Collection<Long> m_allResponsibleContactableIds;
    private Collection<Long> m_responsibleContactableIds;
    
    private FormFile m_file;
    
    /** Creates a new instance of ReassignResponsibilityActionForm */
    public ReassignResponsibilityActionForm() {
        m_responsibleContactableIds = new ArrayList<Long>();
    }
    
    public String getMessage() {
        return m_message;
    }
    
    public void setMessage(String message) {
        m_message = message;
    }
    
    public Collection<Long> getAllResponsibleContactableIds() {
        return m_allResponsibleContactableIds;
    }
    
    public void setAllResponsibleContactableIds(Collection<Long> allResponsibleContactableIds) {
        m_allResponsibleContactableIds = allResponsibleContactableIds;
    }
    
    public Collection<Long> getResponsibleContactableIds() {
        return m_responsibleContactableIds;
    }
    
    public void setResponsibleContactableIds(Collection<Long> responsibleContactableIds) {
        m_responsibleContactableIds = responsibleContactableIds;
    }
    
    public FormFile getFile() {
        return m_file;
    }
    
    public void setFile(FormFile file) {
        m_file = file;
    }
    
    /**
     * Check to make sure the client hasn't exceeded the maximum allowed upload size inside of this
     * validate method.
     */
    @Override
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = null;
        //has the maximum length been exceeded?
        Boolean maxLengthExceeded = (Boolean)request.getAttribute(MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED);
        if ((maxLengthExceeded != null) && (maxLengthExceeded.booleanValue())) {
            errors = new ActionErrors();
            errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.file.maxLengthExceeded"));
            errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.file.maxLengthExplanation"));
        }
        return errors;
    }

}
